<template>
  <div id="index">
    <Header :activeIndex="nav" :isLogin="isLogin" :title='title'>
      <li @click="goPage('Home')" v-if="nav != 'Home'">首页</li>
    </Header>

    <div id="body">
      <router-view class="index-view" @isTitle="getisTitel"></router-view>
    </div>

    <Footer></Footer>
    <el-backtop target="#index"></el-backtop>
  </div>
</template>

<script>
import "@/assets/less/base.less";
import Header from "@/components/Header";
import Footer from "@/components/Footer";
export default {
  name: "index",
  components: {
    Header,
    Footer,
  },
  data() {
    return {
      title: '落新家',
      nav: 'home',
      isLogin: false,
    }
  },
  created() {
    if (this.$cookies.get('__tk')) {
      this.isLogin = true;
    } else {
      this.isLogin = false;
    }
  },
  mounted() {
    if (this.$cookies.get('__tk')) {
      this.isLogin = true;
    } else {
      this.isLogin = false;
    }
    // console.log('index mounted==>', 1)
    this.un = this.$cookies.get('__un');
    this.$nextTick(() => {
      document.body.scrollTo(0, 0);
      window.scrollTo(0, 0);
      document.getElementById('index').scrollTop = 0
      window.pageYOffset = 0;
    })
  },
  methods: {
    // 跳转
    goPage(n) {
      this.$router.push({ name: n });
    },
    // 
    getisTitel(t) {
      // console.log('oj==>', t)
      this.title = t.title || "落新家";
      this.nav = t.nav || "home";
      this.isLogin = t.isLogin || false;
    },
  }
};
</script>

<style lang="less" scoped>
#index {
  height: 100vh;
  width: 100vw;
  overflow-x: hidden;
  // overflow-y: auto;
}
#body {
  // display: flex;
  width: 100%;
  /* height: calc(100vh - 80px - 370px); */
}

.index-view {
  width: 100%;
  /* position: relative; */
  /* background-color:#fff; */
}
</style>